Read in the packages. The working directory is wherever the R Notebook is located.
Read in the spreadsheet and take a look at the data. There is one outlier (acan-sp_68). I’m throwing it out here, but need to ask about original coordinates.
Plot a leaflet map of the localities. The leaflet map is interactive. You can click on the localities and a flag with some metadata will pop up!
#use sourced plot_locs_leaflet script to plot localities
all_plot <- plot_locs_leaflet(loc)Assuming "longitude" and "latitude" are longitude and latitude, respectively
all_plotObtain the bioclim layers for analysis. I’m using all 19 for this preliminary exploration. I plotted the first bioclim just to make sure nothing seems wonky.
##get worldclim data
w <- getData("worldclim", var = "bio", res = 0.5, lon = 173, lat = -35)This is a PCA of the climate data extracted for each locality, rather than a PCA of the total climate space.
Run the pca and check out variable loadings and proportion of variance explained by components.
#extract data from worldclim for each locality. Making this into a data frame with columns labeled so the row labeling lines up after I remove the NAs.
#extract data from worldclim for each locality.
coords <- data.frame(latitude = loc$longitude, longitude = loc$latitude)
loc.clim <- dplyr::bind_cols(loc, raster::extract(w, coords, method = "simple", df = TRUE)) %>%
na.omit() %>%
select(-ID)
#make a matrix of only bioclim values
clim.mat <- loc.clim[,grep("bio", names(loc.clim))] %>% as.matrix()
#run pca on climate variables
clim.pca <- prcomp(clim.mat, scale = TRUE)
summary.pca <- summary(clim.pca) #check out the componentsTwo plots: One plot of the PCA colored according to genus, with convex hulls surrounding the genera. It looks like this reflects a latitudinal gradient in temperature! You can interact with the PCA plot by clicking on points to view associated metadata. You can isolate the genus you want to view by double clicking the genus in the legend! You can also remove a genus by clicking on it once. There’s some other functionality you can explore in the toolbar at the top of the plot.
#add pca results to loc.clim data frame
loc.clim <- data.frame(loc.clim, clim.pca$x)Error in data.frame(loc.clim, clim.pca$x) :
arguments imply differing number of rows: 568, 19
#plot tables
summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.8205 2.5959 1.29925 1.03634 0.86397 0.75029 0.35359 0.22905 0.13868
Proportion of Variance 0.4187 0.3547 0.08885 0.05653 0.03929 0.02963 0.00658 0.00276 0.00101
Cumulative Proportion 0.4187 0.7734 0.86222 0.91874 0.95803 0.98766 0.99424 0.99700 0.99801
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17 PC18
Standard deviation 0.11203 0.09749 0.0756 0.07171 0.04711 0.03566 0.03063 0.01582 0.01221
Proportion of Variance 0.00066 0.00050 0.0003 0.00027 0.00012 0.00007 0.00005 0.00001 0.00001
Cumulative Proportion 0.99867 0.99917 0.9995 0.99975 0.99986 0.99993 0.99998 0.99999 1.00000
PC19
Standard deviation 7.859e-16
Proportion of Variance 0.000e+00
Cumulative Proportion 1.000e+00
knitr::kable(round(clim.pca$rotation[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.343 | -0.023 | -0.148 |
| bio2_411 | 0.248 | 0.051 | -0.528 |
| bio3_411 | -0.133 | 0.040 | -0.425 |
| bio4_411 | 0.302 | 0.062 | -0.295 |
| bio5_411 | -0.297 | -0.009 | -0.376 |
| bio6_411 | -0.352 | -0.029 | 0.000 |
| bio7_411 | 0.284 | 0.041 | -0.420 |
| bio8_411 | -0.191 | 0.046 | -0.205 |
| bio9_411 | -0.297 | -0.060 | 0.060 |
| bio10_411 | -0.332 | -0.017 | -0.220 |
| bio11_411 | -0.349 | -0.034 | -0.072 |
| bio12_411 | 0.048 | -0.381 | -0.005 |
| bio13_411 | 0.009 | -0.381 | -0.033 |
| bio14_411 | 0.050 | -0.372 | -0.064 |
| bio15_411 | -0.208 | -0.006 | -0.057 |
| bio16_411 | 0.004 | -0.382 | -0.016 |
| bio17_411 | 0.076 | -0.372 | -0.024 |
| bio18_411 | 0.081 | -0.364 | -0.073 |
| bio19_411 | -0.038 | -0.369 | 0.002 |
These are PCAs of environmental space for species within genera. Each climate PCA is of localities for a single genus, colored by species. I’m doing this even for genera with one species, so it’s easy to see if certain localities group together.
#source function to conduct a PCA on individual species
summary.list.acan <- species_pca_fun(loc.clim, "acanthoxyla")
#plot
plot_clim_pca(summary.list.acan$loc.clim, summary.list.acan$summary.pca)Ignoring unknown aesthetics: text
summary.list.acan$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.8976 2.4081 1.4499 1.03416 0.99391 0.64837 0.37316 0.17888 0.15065
Proportion of Variance 0.4419 0.3052 0.1106 0.05629 0.05199 0.02213 0.00733 0.00168 0.00119
Cumulative Proportion 0.4419 0.7471 0.8578 0.91404 0.96603 0.98816 0.99549 0.99717 0.99836
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.10865 0.07958 0.07073 0.05713 0.05208 0.03016 0.02200 0.01953
Proportion of Variance 0.00062 0.00033 0.00026 0.00017 0.00014 0.00005 0.00003 0.00002
Cumulative Proportion 0.99899 0.99932 0.99958 0.99975 0.99990 0.99994 0.99997 0.99999
PC18 PC19
Standard deviation 0.01351 4.091e-16
Proportion of Variance 0.00001 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.acan <- summary.list.acan$summary.pca$rotation
knitr::kable(round(loadings.acan[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.220 | -0.303 | 0.131 |
| bio2_411 | 0.191 | 0.155 | 0.499 |
| bio3_411 | -0.062 | 0.141 | 0.324 |
| bio4_411 | 0.244 | 0.106 | 0.354 |
| bio5_411 | -0.152 | -0.279 | 0.381 |
| bio6_411 | -0.256 | -0.274 | -0.004 |
| bio7_411 | 0.232 | 0.117 | 0.434 |
| bio8_411 | -0.027 | -0.275 | -0.091 |
| bio9_411 | -0.251 | -0.172 | 0.116 |
| bio10_411 | -0.197 | -0.308 | 0.204 |
| bio11_411 | -0.243 | -0.289 | 0.059 |
| bio12_411 | 0.284 | -0.232 | -0.046 |
| bio13_411 | 0.268 | -0.253 | 0.009 |
| bio14_411 | 0.289 | -0.219 | -0.049 |
| bio15_411 | -0.146 | -0.087 | 0.300 |
| bio16_411 | 0.264 | -0.256 | -0.004 |
| bio17_411 | 0.293 | -0.211 | -0.065 |
| bio18_411 | 0.295 | -0.205 | -0.054 |
| bio19_411 | 0.220 | -0.277 | 0.039 |
#conduct pca
summary.list.argo <- species_pca_fun(loc.clim, "argosarchus")
#plot
plot_clim_pca(summary.list.argo$loc.clim, summary.list.argo$summary.pca)Ignoring unknown aesthetics: text
summary.list.argo$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.6107 2.5769 1.5880 1.08155 0.94245 0.84133 0.3698 0.2092 0.1509
Proportion of Variance 0.3587 0.3495 0.1327 0.06157 0.04675 0.03725 0.0072 0.0023 0.0012
Cumulative Proportion 0.3587 0.7082 0.8409 0.90251 0.94926 0.98652 0.9937 0.9960 0.9972
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.13650 0.12389 0.08684 0.07717 0.05097 0.03317 0.02797 0.02345
Proportion of Variance 0.00098 0.00081 0.00040 0.00031 0.00014 0.00006 0.00004 0.00003
Cumulative Proportion 0.99820 0.99900 0.99940 0.99971 0.99985 0.99991 0.99995 0.99998
PC18 PC19
Standard deviation 0.02016 3.848e-16
Proportion of Variance 0.00002 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.argo <- summary.list.argo$summary.pca$rotation
knitr::kable(round(loadings.argo[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | 0.253 | -0.268 | -0.137 |
| bio2_411 | -0.139 | 0.198 | -0.487 |
| bio3_411 | 0.018 | 0.020 | -0.421 |
| bio4_411 | -0.210 | 0.213 | -0.300 |
| bio5_411 | 0.192 | -0.174 | -0.437 |
| bio6_411 | 0.254 | -0.286 | 0.040 |
| bio7_411 | -0.166 | 0.222 | -0.418 |
| bio8_411 | -0.038 | -0.077 | 0.082 |
| bio9_411 | 0.223 | -0.227 | -0.115 |
| bio10_411 | 0.239 | -0.247 | -0.233 |
| bio11_411 | 0.265 | -0.272 | -0.049 |
| bio12_411 | 0.281 | 0.261 | 0.038 |
| bio13_411 | 0.303 | 0.232 | -0.003 |
| bio14_411 | 0.246 | 0.289 | 0.045 |
| bio15_411 | 0.133 | -0.160 | -0.152 |
| bio16_411 | 0.307 | 0.228 | 0.007 |
| bio17_411 | 0.248 | 0.289 | 0.046 |
| bio18_411 | 0.225 | 0.305 | 0.047 |
| bio19_411 | 0.331 | 0.173 | -0.032 |
#pca
summary.list.aste <- species_pca_fun(loc.clim, "asteliaphasma")
#plot
plot_clim_pca(summary.list.aste$loc.clim, summary.list.aste$summary.pca)Ignoring unknown aesthetics: text
summary.list.aste$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 3.5289 1.9449 1.08847 0.93035 0.68419 0.40024 0.19212 0.13894 0.10016
Proportion of Variance 0.6554 0.1991 0.06236 0.04556 0.02464 0.00843 0.00194 0.00102 0.00053
Cumulative Proportion 0.6554 0.8545 0.91687 0.96242 0.98706 0.99549 0.99743 0.99845 0.99898
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.09172 0.05687 0.05344 0.04780 0.03677 0.02653 0.02020 0.01274
Proportion of Variance 0.00044 0.00017 0.00015 0.00012 0.00007 0.00004 0.00002 0.00001
Cumulative Proportion 0.99942 0.99959 0.99974 0.99986 0.99993 0.99997 0.99999 1.00000
PC18 PC19
Standard deviation 9.137e-16 2.186e-16
Proportion of Variance 0.000e+00 0.000e+00
Cumulative Proportion 1.000e+00 1.000e+00
loadings.aste <- summary.list.aste$summary.pca$rotation
knitr::kable(round(loadings.aste[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.264 | -0.159 | -0.068 |
| bio2_411 | 0.226 | 0.164 | -0.445 |
| bio3_411 | -0.069 | -0.207 | -0.688 |
| bio4_411 | 0.243 | 0.193 | -0.241 |
| bio5_411 | -0.245 | -0.123 | -0.322 |
| bio6_411 | -0.261 | -0.190 | 0.087 |
| bio7_411 | 0.234 | 0.203 | -0.314 |
| bio8_411 | -0.264 | -0.175 | 0.009 |
| bio9_411 | -0.225 | -0.102 | -0.134 |
| bio10_411 | -0.260 | -0.151 | -0.114 |
| bio11_411 | -0.264 | -0.177 | -0.001 |
| bio12_411 | 0.239 | -0.272 | 0.017 |
| bio13_411 | 0.203 | -0.349 | -0.021 |
| bio14_411 | 0.230 | -0.260 | 0.112 |
| bio15_411 | -0.148 | -0.237 | -0.093 |
| bio16_411 | 0.210 | -0.341 | 0.022 |
| bio17_411 | 0.246 | -0.227 | 0.041 |
| bio18_411 | 0.229 | -0.275 | -0.022 |
| bio19_411 | 0.210 | -0.341 | 0.021 |
Marginal climate hypothesis workspace. Resample from sister species data set and calculate average per sample. Compare absolute value of range-restricted species to distribution of sister species averages. Need to work on a suitable statistical test.
#calculate the centroid of a random sample of individuals. df = data frame, sp = string containing the species you are interested (e.g. "naomi"), len = the number of individuals to sample. Should be the number of individuals from the species that has fewer occurrences.
#calculate the centroid from the range-restricted species.
pc.centroid.nov <- summary.list.aste$loc.clim %>%
filter(species == "nov. sp.") %>%
select(PC1.1:PC3.1) %>%
summarize_all(mean) %>%
rowMeans() %>%
abs()
#resample the more widespread species many times, calculating the centroid of three individuals (number of individuals in the range-restricted species)
pc.centroid.naomi <- replicate(1000, pc_centroid_fun(summary.list.aste$loc.clim, "naomi", 3), simplify = TRUE) %>%
as.data.frame()
names(pc.centroid.naomi) <- "centroid" #needs to be a data frame with a named column for ggplot
#sampling distribution of the centroids calculated from the generalist species. The red line indicates the centroid of the range-restricted species
ggplot(pc.centroid.naomi, aes(x = centroid)) +
geom_histogram(bins = 30) +
#scale_x_sqrt() +
geom_vline(xintercept = pc.centroid.nov, color = "red") +
theme_linedraw()Outlying Mean Index. Another test of the marginal niche hypothesis.
aste_omi$test_omiclass: krandtest lightkrandtest
Monte-Carlo tests
Call: as.krandtest(sim = t(sim), obs = obs)
Number of tests: 3
Adjustment method for multiple comparisons: none
Permutation number: 1000
NA
summary.list.clita <- species_pca_fun(loc.clim, "clitarchus")
plot_clim_pca(summary.list.clita$loc.clim, summary.list.clita$summary.pca)Ignoring unknown aesthetics: text
summary.list.clita$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.8287 2.6276 1.32815 1.1156 0.73394 0.53892 0.3776 0.22177 0.14594
Proportion of Variance 0.4211 0.3634 0.09284 0.0655 0.02835 0.01529 0.0075 0.00259 0.00112
Cumulative Proportion 0.4211 0.7845 0.87737 0.9429 0.97121 0.98650 0.9940 0.99659 0.99771
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.13870 0.10155 0.07717 0.06308 0.04870 0.02999 0.01809 0.01515
Proportion of Variance 0.00101 0.00054 0.00031 0.00021 0.00012 0.00005 0.00002 0.00001
Cumulative Proportion 0.99873 0.99927 0.99958 0.99979 0.99992 0.99996 0.99998 0.99999
PC18 PC19
Standard deviation 0.01187 5.086e-16
Proportion of Variance 0.00001 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.clita <- summary.list.clita$summary.pca$rotation
knitr::kable(round(loadings.clita[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.317 | -0.142 | -0.099 |
| bio2_411 | 0.129 | 0.256 | -0.457 |
| bio3_411 | -0.166 | 0.081 | -0.530 |
| bio4_411 | 0.252 | 0.216 | -0.236 |
| bio5_411 | -0.305 | -0.055 | -0.299 |
| bio6_411 | -0.304 | -0.191 | 0.037 |
| bio7_411 | 0.182 | 0.251 | -0.355 |
| bio8_411 | -0.189 | -0.209 | 0.105 |
| bio9_411 | -0.280 | -0.066 | -0.167 |
| bio10_411 | -0.314 | -0.119 | -0.152 |
| bio11_411 | -0.318 | -0.157 | -0.040 |
| bio12_411 | -0.176 | 0.322 | 0.126 |
| bio13_411 | -0.207 | 0.294 | 0.060 |
| bio14_411 | -0.180 | 0.303 | 0.161 |
| bio15_411 | -0.140 | -0.061 | -0.250 |
| bio16_411 | -0.211 | 0.293 | 0.078 |
| bio17_411 | -0.145 | 0.332 | 0.151 |
| bio18_411 | -0.149 | 0.325 | 0.149 |
| bio19_411 | -0.216 | 0.289 | 0.067 |
Marginal environment hypothesis
#calculate the centroid from the range-restricted species.
pc.centroid.tepaki <- summary.list.clita$loc.clim %>%
filter(species == "tepaki") %>%
select(PC1.1:PC3.1) %>%
summarize_all(mean) %>%
rowMeans() %>%
abs()
pc.centroid.hookeri <- replicate(1000, pc_centroid_fun(summary.list.clita$loc.clim, "hookeri", 3), simplify = TRUE) %>%
as.data.frame()
names(pc.centroid.hookeri) <- "centroid"
ggplot(pc.centroid.hookeri, aes(x = centroid)) +
geom_histogram(bins = 30) +
#scale_x_sqrt() +
geom_vline(xintercept = pc.centroid.tepaki, color = "red") +
theme_linedraw()#length(pc.centroid.hookeri$centroid[pc.centroid.hookeri$centroid > pc.centroid.tepaki])Outlying Mean Index. Another test of the marginal niche hypothesis.
clita_omi$test_omiclass: krandtest lightkrandtest
Monte-Carlo tests
Call: as.krandtest(sim = t(sim), obs = obs)
Number of tests: 3
Adjustment method for multiple comparisons: none
Permutation number: 1000
NA
summary.list.micra <- species_pca_fun(loc.clim, "micrarchus")
plot_clim_pca(summary.list.micra$loc.clim, summary.list.micra$summary.pca)Ignoring unknown aesthetics: text
summary.list.micra$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 3.4602 1.8070 1.4755 1.04628 0.47265 0.37427 0.28044 0.13523 0.12413
Proportion of Variance 0.6302 0.1719 0.1146 0.05762 0.01176 0.00737 0.00414 0.00096 0.00081
Cumulative Proportion 0.6302 0.8020 0.9166 0.97422 0.98598 0.99335 0.99749 0.99846 0.99927
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.08040 0.04868 0.04396 0.03954 0.02696 0.01967 0.01488 0.01171
Proportion of Variance 0.00034 0.00012 0.00010 0.00008 0.00004 0.00002 0.00001 0.00001
Cumulative Proportion 0.99961 0.99973 0.99983 0.99992 0.99995 0.99998 0.99999 0.99999
PC18 PC19
Standard deviation 0.01059 2.802e-16
Proportion of Variance 0.00001 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.micra <- summary.list.micra$summary.pca$rotation
knitr::kable(round(loadings.micra[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | 0.265 | 0.140 | 0.187 |
| bio2_411 | 0.044 | -0.384 | 0.474 |
| bio3_411 | 0.215 | -0.052 | 0.376 |
| bio4_411 | -0.145 | -0.454 | 0.113 |
| bio5_411 | 0.264 | 0.036 | 0.260 |
| bio6_411 | 0.264 | 0.203 | 0.092 |
| bio7_411 | -0.069 | -0.439 | 0.365 |
| bio8_411 | 0.183 | 0.271 | 0.080 |
| bio9_411 | 0.265 | 0.137 | 0.127 |
| bio10_411 | 0.266 | 0.105 | 0.207 |
| bio11_411 | 0.264 | 0.171 | 0.164 |
| bio12_411 | -0.259 | 0.189 | 0.187 |
| bio13_411 | -0.253 | 0.205 | 0.199 |
| bio14_411 | -0.256 | 0.177 | 0.201 |
| bio15_411 | 0.130 | 0.077 | 0.062 |
| bio16_411 | -0.252 | 0.206 | 0.204 |
| bio17_411 | -0.256 | 0.184 | 0.209 |
| bio18_411 | -0.255 | 0.186 | 0.211 |
| bio19_411 | -0.254 | 0.175 | 0.189 |
summary.list.nive <- species_pca_fun(loc.clim, "niveaphasma")
plot_clim_pca(summary.list.nive$loc.clim, summary.list.nive$summary.pca)Ignoring unknown aesthetics: text
summary.list.nive$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.9075 2.3439 1.6667 1.03074 0.77498 0.58305 0.48456 0.11336 0.09999
Proportion of Variance 0.4449 0.2892 0.1462 0.05592 0.03161 0.01789 0.01236 0.00068 0.00053
Cumulative Proportion 0.4449 0.7341 0.8803 0.93621 0.96782 0.98571 0.99807 0.99874 0.99927
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.07972 0.05147 0.04226 0.03754 0.02765 0.02184 0.01340 0.01209
Proportion of Variance 0.00033 0.00014 0.00009 0.00007 0.00004 0.00003 0.00001 0.00001
Cumulative Proportion 0.99960 0.99974 0.99984 0.99991 0.99995 0.99998 0.99999 0.99999
PC18 PC19
Standard deviation 0.01062 7.143e-16
Proportion of Variance 0.00001 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.nive <- summary.list.nive$summary.pca$rotation
knitr::kable(round(loadings.nive[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.212 | -0.286 | 0.234 |
| bio2_411 | -0.053 | 0.355 | 0.221 |
| bio3_411 | -0.050 | -0.292 | -0.117 |
| bio4_411 | -0.042 | 0.388 | 0.209 |
| bio5_411 | -0.218 | 0.082 | 0.424 |
| bio6_411 | -0.139 | -0.385 | 0.066 |
| bio7_411 | -0.027 | 0.387 | 0.230 |
| bio8_411 | -0.218 | -0.008 | 0.258 |
| bio9_411 | -0.002 | -0.238 | 0.191 |
| bio10_411 | -0.245 | -0.148 | 0.347 |
| bio11_411 | -0.155 | -0.369 | 0.118 |
| bio12_411 | 0.322 | -0.071 | 0.184 |
| bio13_411 | 0.314 | -0.077 | 0.217 |
| bio14_411 | 0.329 | -0.061 | 0.130 |
| bio15_411 | -0.150 | 0.011 | 0.384 |
| bio16_411 | 0.315 | -0.087 | 0.205 |
| bio17_411 | 0.330 | -0.054 | 0.145 |
| bio18_411 | 0.319 | -0.067 | 0.185 |
| bio19_411 | 0.326 | -0.079 | 0.148 |
summary.list.spin <- species_pca_fun(loc.clim, "spinotectarchus")
plot_clim_pca(summary.list.spin$loc.clim, summary.list.spin$summary.pca)Ignoring unknown aesthetics: text
summary.list.spin$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 3.6740 1.7717 1.04961 0.74836 0.67601 0.41693 0.17179 0.13411 0.09313
Proportion of Variance 0.7105 0.1652 0.05798 0.02948 0.02405 0.00915 0.00155 0.00095 0.00046
Cumulative Proportion 0.7105 0.8757 0.93363 0.96311 0.98716 0.99631 0.99786 0.99881 0.99927
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.07134 0.05938 0.05019 0.03604 0.02482 0.02193 0.01971 6.967e-16
Proportion of Variance 0.00027 0.00019 0.00013 0.00007 0.00003 0.00003 0.00002 0.000e+00
Cumulative Proportion 0.99954 0.99972 0.99985 0.99992 0.99995 0.99998 1.00000 1.000e+00
PC18 PC19
Standard deviation 1.6e-17 2.958e-18
Proportion of Variance 0.0e+00 0.000e+00
Cumulative Proportion 1.0e+00 1.000e+00
loadings.spin <- summary.list.spin$summary.pca$rotation
knitr::kable(round(loadings.spin[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | -0.257 | -0.130 | -0.194 |
| bio2_411 | 0.230 | 0.165 | -0.351 |
| bio3_411 | -0.106 | -0.360 | -0.197 |
| bio4_411 | 0.230 | 0.233 | -0.239 |
| bio5_411 | -0.239 | -0.097 | -0.390 |
| bio6_411 | -0.254 | -0.197 | 0.014 |
| bio7_411 | 0.228 | 0.235 | -0.273 |
| bio8_411 | -0.258 | -0.165 | -0.104 |
| bio9_411 | -0.215 | -0.014 | -0.395 |
| bio10_411 | -0.252 | -0.109 | -0.265 |
| bio11_411 | -0.258 | -0.165 | -0.104 |
| bio12_411 | 0.239 | -0.264 | -0.037 |
| bio13_411 | 0.220 | -0.323 | 0.010 |
| bio14_411 | 0.240 | -0.237 | -0.137 |
| bio15_411 | -0.152 | -0.249 | 0.447 |
| bio16_411 | 0.221 | -0.322 | 0.029 |
| bio17_411 | 0.247 | -0.211 | -0.129 |
| bio18_411 | 0.238 | -0.241 | -0.172 |
| bio19_411 | 0.221 | -0.322 | 0.029 |
Marginal environment hypothesis
#calculate the centroid from the range-restricted species.
pc.centroid.acornutus_sub <- summary.list.spin$loc.clim %>%
filter(species == "acornutus_sub") %>%
select(PC1.1:PC3.1) %>%
summarize_all(mean) %>%
rowMeans() %>%
abs()
pc.centroid.acornutus <- replicate(1000, pc_centroid_fun(summary.list.spin$loc.clim, "acornutus", 3), simplify = TRUE) %>%
as.data.frame()
names(pc.centroid.acornutus) <- "centroid"
ggplot(pc.centroid.acornutus, aes(x = centroid)) +
geom_histogram(bins = 30) +
#scale_x_sqrt() +
geom_vline(xintercept = pc.centroid.acornutus_sub, color = "red") +
theme_linedraw()Outlying Mean Index. Another test of the marginal niche hypothesis.
spin_omi$test_omiclass: krandtest lightkrandtest
Monte-Carlo tests
Call: as.krandtest(sim = t(sim), obs = obs)
Number of tests: 3
Adjustment method for multiple comparisons: none
Permutation number: 1000
NA
summary.list.tect <- species_pca_fun(loc.clim, "tectarchus")
plot_clim_pca(summary.list.tect$loc.clim, summary.list.tect$summary.pca)Ignoring unknown aesthetics: text
summary.list.tect$summary.pcaImportance of components:
PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9
Standard deviation 2.7649 2.5672 1.5947 1.13698 0.63754 0.57252 0.35428 0.1689 0.11908
Proportion of Variance 0.4024 0.3469 0.1338 0.06804 0.02139 0.01725 0.00661 0.0015 0.00075
Cumulative Proportion 0.4024 0.7492 0.8831 0.95112 0.97251 0.98976 0.99637 0.9979 0.99862
PC10 PC11 PC12 PC13 PC14 PC15 PC16 PC17
Standard deviation 0.11043 0.07835 0.05082 0.04736 0.04012 0.02414 0.02156 0.01715
Proportion of Variance 0.00064 0.00032 0.00014 0.00012 0.00008 0.00003 0.00002 0.00002
Cumulative Proportion 0.99926 0.99958 0.99972 0.99984 0.99992 0.99995 0.99998 0.99999
PC18 PC19
Standard deviation 0.01214 4.565e-16
Proportion of Variance 0.00001 0.000e+00
Cumulative Proportion 1.00000 1.000e+00
loadings.tect <- summary.list.tect$summary.pca$rotation
knitr::kable(round(loadings.tect[,1:3],3)) #Table of loading scores for the first 3 PCs. | PC1 | PC2 | PC3 | |
|---|---|---|---|
| bio1_411 | 0.309 | -0.182 | 0.117 |
| bio2_411 | -0.122 | 0.137 | 0.539 |
| bio3_411 | 0.159 | -0.033 | 0.464 |
| bio4_411 | -0.214 | 0.247 | 0.289 |
| bio5_411 | 0.273 | -0.146 | 0.318 |
| bio6_411 | 0.306 | -0.201 | -0.020 |
| bio7_411 | -0.175 | 0.158 | 0.465 |
| bio8_411 | 0.221 | -0.137 | -0.105 |
| bio9_411 | 0.268 | -0.200 | 0.100 |
| bio10_411 | 0.305 | -0.167 | 0.181 |
| bio11_411 | 0.304 | -0.205 | 0.060 |
| bio12_411 | -0.211 | -0.315 | 0.021 |
| bio13_411 | -0.209 | -0.310 | 0.040 |
| bio14_411 | -0.214 | -0.304 | 0.069 |
| bio15_411 | 0.058 | 0.027 | 0.082 |
| bio16_411 | -0.204 | -0.316 | 0.036 |
| bio17_411 | -0.216 | -0.306 | 0.038 |
| bio18_411 | -0.223 | -0.299 | 0.038 |
| bio19_411 | -0.197 | -0.314 | 0.061 |
Nothing. Only one locality.
Outlying Mean Index. Another test of the marginal niche hypothesis.
all_omi$test_omiclass: krandtest lightkrandtest
Monte-Carlo tests
Call: as.krandtest(sim = t(sim), obs = obs)
Number of tests: 17
Adjustment method for multiple comparisons: none
Permutation number: 1000
NA